Teknik Şartname
Durum
Bu doküman Form Builder'ın mevcut durumunu ve geliştirilecek özellikleri detaylandırır.
Mevcut Durum (%70)
Tamamlanan Özellikler
interface FormBuilderCore {
// ✅ Implemented
dynamicRendering: {
conditionalFields: true;
conditionalCategories: true;
conditionalStyling: true;
};
componentSupport: {
maComponents: true;
customComponents: true;
dynamicImports: true;
};
stateManagement: {
controlled: true;
uncontrolled: true;
};
validation: {
zodIntegration: true;
typeSafety: true;
};
uiStates: {
loading: true;
error: true;
skeleton: true;
};
}
Functional Patterns
// ✅ Implemented Hooks
const useFieldProps = (fieldName: string) => {
// Field props management
};
const useFieldComponent = (fieldType: string) => {
// Dynamic component resolution
};
const useFieldError = (fieldName: string) => {
// Error state management
};
Geliştirilecek Özellikler
Dynamic Schema Generation
interface DynamicSchemaConfig {
userRole: string;
companySettings: CompanySettings;
featureFlags: FeatureFlags;
}
// 🔄 To Be Implemented
const useDynamicSchema = (config: DynamicSchemaConfig) => {
return {
fields: generateFieldsByRole(config),
validation: generateValidationByRole(config),
layout: generateLayoutByRole(config),
};
};
Custom Component Registry
// 🔄 To Be Implemented
interface ComponentRegistry {
register: (type: string, component: React.ComponentType) => void;
resolve: (type: string) => React.ComponentType;
}
const useComponentRegistry = () => {
const register = (type, component) => {
// Register custom component
};
const resolve = (type) => {
// Resolve component by type
};
return { register, resolve };
};
Feature Level Integration
// 🔄 Example Usage
const TripReportForm = () => {
const { role } = useUser();
const { settings } = useCompany();
const { flags } = useFeatureFlags();
// Dynamic schema generation
const schema = useDynamicSchema({
userRole: role,
companySettings: settings,
featureFlags: flags,
});
// Custom component registration
const registry = useComponentRegistry();
registry.register("customExpenseField", CustomExpenseComponent);
return (
<FormBuilder
schema={schema}
componentRegistry={registry}
onSubmit={handleSubmit}
/>
);
};
Yeni Component Interface
interface FormField {
type: string; // Allow any string for custom components
name: string;
label: string;
condition?: (context: FormContext) => boolean;
component?: React.ComponentType<any>; // Optional custom component
props?: Record<string, any>; // Custom props
validation?: z.ZodType | ((context: FormContext) => z.ZodType);
layout?: {
category?: string;
order?: number;
styling?: (context: FormContext) => React.CSSProperties;
};
}
interface FormContext {
userRole: string;
companySettings: CompanySettings;
featureFlags: FeatureFlags;
formValues: Record<string, any>;
}
interface FormBuilderProps {
schema: FormSchema | ((context: FormContext) => FormSchema);
componentRegistry?: ComponentRegistry;
context: FormContext;
onSubmit: (values: any) => Promise<void>;
}
Yeni Mimari
Performance Optimizasyonu
Context-Based Memoization
const MemoizedField = React.memo(FieldRenderer, (prev, next) => {
return (
prev.value === next.value &&
prev.error === next.error &&
prev.context === next.context &&
prev.field === next.field
);
});
Schema Caching
const useSchemaCache = (config: DynamicSchemaConfig) => {
return useMemo(() => {
return generateSchema(config);
}, [config.userRole, config.companySettings, config.featureFlags]);
};
Önemli Not
Form Builder'ın mevcut implementasyonu solid bir temel sağlıyor. Yeni geliştirmeler, bu temelin üzerine dynamic schema generation ve custom component support özelliklerini ekleyecek.